package com.sxbbc.common.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sxbbc.common.core.entity.jz.CAccount;
import com.sxbbc.common.core.mapper.jz.CAccountMapper;
import com.sxbbc.common.core.service.ICAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * <p>
 * 用户资金账户表 服务实现类
 * </p>
 *
 * @author leehao
 * @since 2019-05-07
 */
@Service
public class CAccountServiceImpl extends ServiceImpl<CAccountMapper, CAccount> implements ICAccountService {

    @Autowired
    private CAccountMapper accountMapper;


    @Override
    public CAccount selectByCid(Integer cid) {
        QueryWrapper<CAccount> wrapper = new QueryWrapper<>();
        wrapper.eq("cid",cid);
        return super.getOne(wrapper);
    }

    @Override
    public boolean updateByCid(CAccount cAccount) {
        QueryWrapper<CAccount> wrapper = new QueryWrapper<>();
        wrapper.eq("cid",cAccount.getCid());
        return super.update(cAccount,wrapper);
    }

    @Override
    public BigDecimal sumAccount() {
        return accountMapper.sumTotalByType(1);
    }
}
